<!--
 * @Author: coman
 * @LastEditors: coman
 * @Date: 2020-06-18 18:50:02
 * @motto: No pain,No gain
 * @LastEditTime: 2020-06-18 19:00:07
--> 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 注意点: str的值存在栈中,无法改变里面的值 只能通过创建一个变量接收变化后的值-->
    <script>
         var str = 'asdasdSMasdasdasdSMsdasdasdSMsadasd';
         res = str.replace("SM","**");
         while(res.indexOf("SM")!==-1){
             res =res.replace("SM","**");
         }
         console.log(res);
         
    </script>
</body>
</html>